
<template>
  <view class="app-container">
    <view class="center col ae">
      <Upload  :file="user.avatar" tag="avatar" type="3" class="head-icon" />
      点击更换头像
    </view> 
    <nut-form>
      <nut-form-item label="姓名">
        <input class="nut-input-text" v-model="user.realname" placeholder="请输入姓名" type="text" />
      </nut-form-item>
      <nut-form-item label="性别">
          {{user.gender?'女':'男'}} <nut-switch v-model="user.gender" />
      </nut-form-item>
       <nut-cell title="出生年月"  :desc="user.birthday" @click="show = true" is-link></nut-cell>
       <Datepicker :show="show" @confirm="confirm"/>
      <nut-form-item label="所在地">
        <input class="nut-input-text" v-model="user.address" placeholder="请输入所在地" type="text" />
      </nut-form-item>
      <nut-form-item label="公司名称">
        <input  v-model="user.companyName" 
          class="nut-input-text"
          placeholder="请输入公司名称"
          type="text"
        />
      </nut-form-item>
      <nut-form-item label="公司地址">
        <input  v-model="user.companyAddress" 
          class="nut-input-text"
          placeholder="请输入公司地址"
          type="text"
        />
      </nut-form-item>
      <nut-form-item label="手机号">
        <input   v-model="user.mobile" 
        class="nut-input-text" 
        placeholder="请输入手机号" @input="inputPhone" />
      </nut-form-item>
      <nut-form-item label="座右铭">
        <nut-textarea 
        v-model="user.motto" 
        placeholder="请输入座右铭" type="text" />
      </nut-form-item>
      <view class="ae2"></view> 
      <nut-form-item label="实名认证">
        <view class="flex">
          <Upload   :file="user.autonymPath1" type="3"  tag="autonymPath1" />
          <Upload  :file="user.autonymPath2" type="3"  tag="autonymPath2" style="margin-left:20px" />
        </view>
      </nut-form-item>
      <view class="ae2"></view> 
      <nut-form-item label="执业经纪认证">
        <view class="flex">
          <Upload  :file="user.brokerPath" type="3" tag="brokerPath"/>
        </view>
      </nut-form-item>
      <view class="ae2"></view> 
      <nut-form-item label="公司认证">
        <view class="flex">
          <Upload  :file="user.companyPath"  type="3" tag="companyPath"/>
        </view>
      </nut-form-item>

      <view class="tip-infos"> 备注:以上认证将在提交后24小时内审核完成。 </view>

      <view class="center">
        <nut-button class="submit btn" color="#FBD100" type="primary" @click="submit">完成提交</nut-button>
      </view>
    </nut-form>

    <view class="center bg"> <view class="appPng"> </view> </view>
 
      
  </view>
</template>
<script>
import Datepicker from '../../common/datepicker.vue'
import Upload from '../../common/uploader.vue'
export default {
  components: { Upload,Datepicker},
  data() {
    return {
      user: {},
      currentDate: new Date(),
      minDate: new Date(1950,1,1),
      maxDate: new Date(),
      show:false,
    };
  },
  created(){
      this.loadUser()
  },
  mounted() {

  },
  methods: {
    loadUser(){
      console.log("获取用户信息");
      var tmp = this.$store.state.apiUserInfo
      console.log(tmp);
      this.user = tmp.data.data
      this.user.autonymPath1 = this.user.autonymPath.split(",")[0]
      this.user.autonymPath2 = this.user.autonymPath.split(",")[1]
      this.user.birthday = this.user.birthday.split(" ")[0]

    },
    confirm (data) {
      this.user.birthday = data
      this.show = false
    },
    inputPhone(e){
      console.log(e.target.value);
    },
    submit(){
      var th = this;
      console.log("获取照片信息");
      var tmp = this.$store.state.tmp
      console.log(tmp);
      var { autonymPath1,autonymPath2} = tmp;
      var autonymPath1 = autonymPath1 + "," + autonymPath2
      console.log( this.user );
      this.user.gender = this.user.gender ? 1 :0;// 1 女性
      this.ajax.post(this.ajax.api.updateUser, Object.assign(this.user,{
      autonymPath1,
      nikename:this.user.realname,
      status:0,
      // autonymPath:this.data.idFileList1[0].url + ',' + this.data.idFileList1[0].url,
      // brokerPath:this.data.codeFileList1[0].url,
      // companyPath:this.data.companyFileList[0].url,
    })).then((res)=>{
      console.log(res); // 提示成功后返回页面
      th.setData({   })
    }); 
    }
  },
};
</script>  

<style>
.flex-content {
  display: flex;
  justify-content: center;
}
.app-container {
  height: 100vh;
  overflow: auto;
  padding-top: 50px;
  font-size: 14px;
}
.up-item {
  margin: 0 10px;
}

.tip-infos {
  padding: 30px;
  color: #ccc;
  font-size: 12px;
}
.submit {
  border-radius: 50px;
  margin: 20px 0 20px 0;
  padding: 0 50px;
  font-size: 20px;
}
.bg{
  background: #ccc;
  padding: 10px;
}
.ae{
  color: #aeaeae;
  font-weight: 400;
  padding-bottom: 10px;
  border-bottom: 10px solid #eee;
}
.ae2{
  width: 100%;
  height: 2px; 
  padding-bottom: 10px;
  border-bottom: 10px solid #eee;
}
.head-icon{
  border: 2px solid #FBD100;
  border-radius: 50%;
  overflow: hidden;
  margin-bottom: 10px;
}
.nut-cell__value{
  width: 65%!important;
  text-align: left!important;
}
</style>